import subprocess
import sys

def main():
    # Check for debug flag
    debug_flag = '--debug' in sys.argv
    
    build_args = [sys.executable, './setup.py', 'build_ext', '--inplace']
    
    if debug_flag:
        build_args.append('--debug')
        print('Building in debug mode...')
    else:
        print('Building in release mode...')
    
    pi = subprocess.Popen(build_args)
    pi.wait()
    return pi.returncode

if __name__ == '__main__':
    exit_code = main()
    sys.exit(exit_code)
